package com.igeek.boot.mapper;

import com.igeek.boot.entity.Incomingstock;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;
import java.util.Map;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author jwj
 * @since 2023-12-26
 */
@Mapper
public interface IncomingstockMapper extends BaseMapper<Incomingstock> {

    @Select("SELECT incoming_name as 'inName',SUM(incoming_quantity) as 'inCount',   \n" +
            "       SUM(incoming_quantity) / (SELECT SUM(incoming_quantity) FROM incomingstock WHERE station = 1) AS 'ratio'  \n" +
            "FROM incomingstock   \n" +
            "WHERE station = 1  \n" +
            "GROUP BY incoming_name  \n" +
            "ORDER BY inCount DESC  \n" +
            "LIMIT 0, #{size};")
    List<Map<String, Object>> selectHotInStock(int size);
}
